package io.xxx.omni.oss.core

/**
 * 使用平台提供的游标拉取数据
 */
abstract class CursorSynchronizer<R> : Synchronizer<R>() {

    override fun fetchAndProcess(context: Context) {
        var response = getResponse(context)
        process(context, response)
        while (hasNext(context, response)) {
            response = getResponse(context, response)
            process(context, response)
        }
    }

    protected abstract fun getResponse(context: Context, response: R? = null): R

    protected abstract fun hasNext(context: Context, response: R): Boolean
}